Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛Fix clusterctl error when reading default config file #2983

Conversation

fabriziopandini
Copy link
Member

What this PR does / why we need it:
This PR fixes #2982 and most specifically

  1. makes clusterctl to configure rules for reading env variables no matter if the config file exists or not
  2. fixes an error in checkDefaultConfig

Which issue(s) this PR fixes:
Fixes #2982

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 29, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 29, 2020
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the tests for this file be updated to reflect these changes?

@ncdc
Copy link
Contributor

ncdc commented Apr 29, 2020

/priority critical-urgent
/milestone v0.3.5
/cc @vincepri

@k8s-ci-robot k8s-ci-robot requested a review from vincepri April 29, 2020 14:04
@k8s-ci-robot k8s-ci-robot added this to the v0.3.5 milestone Apr 29, 2020
@k8s-ci-robot k8s-ci-robot added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Apr 29, 2020
@vincepri
Copy link
Member

@fabriziopandini could you retitle the PR to be more explicit about what we're fixing? PR titles go in release notes

@fabriziopandini fabriziopandini changed the title 🐛fix clusterctl read config 🐛fix clusterctl error when reading default config file Apr 29, 2020
@fabriziopandini
Copy link
Member Author

@JoelSpeed test are already verifying those code path, but injected values were hiding the problem
But I'm not sure we can unit test this in isolation without injecting values

@wfernandes opinions?

@ncdc ncdc changed the title 🐛fix clusterctl error when reading default config file 🐛Fix clusterctl error when reading default config file Apr 29, 2020
@vincepri
Copy link
Member

@wfernandes @fabriziopandini have we run a manual test to make sure the issue is now fixed? We should follow-up, or get better coverage for this edge case either with some unit tests or in one of the e2e tests

@fabriziopandini
Copy link
Member Author

@vincepri I have, but hopefully @wfernandes can double check

@wfernandes
Copy link
Contributor

I'll review this asap.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 29, 2020
@fabriziopandini
Copy link
Member Author

@wfernandes @vincepri I managed to get the test coverage for the error conditions this PR is addressing, so we should have a signal in case a regression is introduced

@wfernandes
Copy link
Contributor

Reviewing

Copy link
Contributor

@wfernandes wfernandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the error in the checkDefaultConfig. I didn't account for the extra "/" in the config path. Thanks for fixing this! And my bad for introducing this in 🙁

Comment on lines +163 to +165
dir, err := ioutil.TempDir("", "clusterctl")
g.Expect(err).NotTo(HaveOccurred())
defer os.RemoveAll(dir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directory is not needed here since the viperReader will have no configPaths for this test case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for noticing this. now I'm using it so the test is isolated from the user config

@wfernandes
Copy link
Contributor

@vincepri @fabriziopandini Do we need to backport this fix to the v0.3.4 that was just released?

@vincepri
Copy link
Member

We'll need to release v0.3.5

@fabriziopandini fabriziopandini force-pushed the fix-clusterctl-read-config branch from b54b500 to 751be4e Compare April 29, 2020 19:36
@fabriziopandini
Copy link
Member Author

squashed commits and addressed pending comment

@wfernandes
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 29, 2020
@k8s-ci-robot k8s-ci-robot merged commit e9a3e37 into kubernetes-sigs:master Apr 29, 2020
@fabriziopandini fabriziopandini deleted the fix-clusterctl-read-config branch May 3, 2020 11:23
@sb1975
Copy link

sb1975 commented Jul 18, 2020

Is this working ? why I am getting error whether I specify in clusterctl.yaml or export as env variable..
kubernetes-sigs/cluster-api-provider-azure#805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error running clusterctl init in v0.3.4
7 participants